package com.tx.springboot_mp.service.impl;/*
 *
 * @author 陈粒
 * @version 创建时间：2021/8/25 9:46
 */

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tx.springboot_mp.mapper.UserMapper;
import com.tx.springboot_mp.pojo.User;
import com.tx.springboot_mp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserServiceimpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    QueryWrapper queryWrapper = new QueryWrapper();

    //查询所有的数据 没有where条件所以参数为null
    @Override
    public List<User> findAll() {

        return userMapper.selectList(null);
    }

    //查询id
    @Override
    public User findUserById(Integer id) {

        return userMapper.selectById(id);
    }

    //查询name和sex
    @Override
    public List<User> findUserByNS(User user) {
        QueryWrapper queryWrapper = new QueryWrapper(user);
        return userMapper.selectList(queryWrapper);
    }

}